#include<stdio.h>  
#include<stdlib.h>  
  
typedef struct Node* List;  
struct Node{  
    int data;  
    struct Node *Next;  
};  
List CreatList(); 
void print(List L);  
void read(List L);  
void combine(List L1,List L2,List L3);  
int main()  
{  
    List L1,L2,L3;  
    L1=CreatList();  
    L2=CreatList();  
    L3=CreatList();  
    read(L1);  
    read(L2);  
    combine(L1,L2,L3);  
    print(L3);  
    return 0;  
}  
List CreatList() 
{  
    List L;
    L=(List)malloc(sizeof(struct Node));  
    if(!L)
    return NULL;  
    L->Next=NULL;  
    return L;  
}  
void print(List L)  
{  
    L=L->Next;  
    if(L==NULL)  
    {  
        printf("NULL");  
        return;  
    }  
    while(L)  
    {  
        if(L->Next==NULL)  
            printf("%d",L->data);  
        else printf("%d ",L->data);  
        L=L->Next;  
    }  
          
}  
void read(List L)  
{  
    List s;  
    int data;  
    scanf("%d",&data);  
    while(data>0)  
    {  
        s=(List)malloc(sizeof(struct Node));  
        if(!s) return;  
        s->data=data;  
        s->Next=NULL;  
        L->Next=s;  
        L=s;  
        scanf("%d",&data);  
    }  
    return;  
}  
void combine(List L1,List L2,List L3)  
{  
    L1=L1->Next;  
    L2=L2->Next;  
    while(L1!=NULL&&L2!=NULL)  
    {  
        if(L1->data>L2->data)  
        {  
            L3->Next=L2;  
            L2=L2->Next;  
        }  
        else  
        {  
            L3->Next=L1;  
            L1=L1->Next;  
        }  
        L3=L3->Next;  
    }  
    if(L1==NULL&&L2==NULL) return;  
    if(L1!=NULL)  
        L3->Next=L1;  
    else L3->Next=L2;  
    return;  
}  
